<%--
  Created by IntelliJ IDEA.
  User: hp
  Date: 2018/8/29
  Time: 19:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style type="text/css">
        #container {width:300px; height: 180px; }
    </style>
    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
    <script src="/static/jquery/jquery-1.9.1.js"></script>
    <script src="https://webapi.amap.com/maps?v=1.4.9&key=f50df840d14861c95415ec7742d42d86"></script>
    <script type="text/javascript">
        $(function () {
            var map = new AMap.Map('container', {
                zoom:11,//级别
                center: [116.397428, 39.90923],//中心点坐标
            });
            //为地图注册click事件获取鼠标点击出的经纬度坐标
            var clickEventListener = map.on('click', function(e) {
                document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat()
            });
            // 创建两个点标记
            var marker1 = new AMap.Marker({
                position: new AMap.LngLat(116.49, 39.9),   // 经纬度对象，如 new AMap.LngLat(116.39, 39.9); 也可以是经纬度构成的一维数组[116.39, 39.9]
                title: '北京'
            });
            var marker2 = new AMap.Marker({
                position: new AMap.LngLat(116.69, 39.9),   // 经纬度对象，如 new AMap.LngLat(116.39, 39.9); 也可以是经纬度构成的一维数组[116.39, 39.9]
                title: '北京'
            });
            map.add(marker1);
            map.add(marker2);
            marker1.on('click', function() {
                alert('您点击了点');

            });
        })
    </script>
</head>
<body>
<div style="width: 1000px;height: 600px" id="container"></div>
</body>
</html>
